package org.netty.server.handler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;

public class NettyServerOutHandler extends ChannelOutboundHandlerAdapter {
	
	private Logger logger = LoggerFactory.getLogger(NettyServerOutHandler.class);
	
	@Override
    public void read(ChannelHandlerContext ctx) throws Exception {
		logger.info("enter ChannelOutboundHandlerAdapter.read !");
        ctx.writeAndFlush("ChannelOutboundHandlerAdapter.read 发来一条消息 \r\n");
        super.read(ctx);
    }

    @Override
    public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
    	logger.info("enter ChannelOutboundHandlerAdapter.write !");
        ctx.writeAndFlush("ChannelOutboundHandlerAdapter.write 发来一条消息 \r\n");
        super.write(ctx, msg, promise);
    }
    
}
